package com.mti.monitor.controller;


import com.mti.monitor.bean.model.SysMonitorUser;
import com.mti.monitor.rst.Result;
import com.mti.monitor.service.SysMonitorUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

@Api(value = "登陆", description = "登陆页")
@RestController
@CrossOrigin
@RequestMapping("login")
public class LoginController {

    @Autowired
    private SysMonitorUserService sysMonitorUserService;

    @ApiOperation(value = "登陆")
    @PostMapping("login")
    public Result check(HttpServletRequest request, @RequestBody SysMonitorUser user) {
        sysMonitorUserService.userExist(user.getUsername(), user.getPassword());
        request.getSession().setAttribute("user", user.getUsername());
        return Result.ok();
    }
}

